package com.da.web.sys_notice.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.da.web.sys_notice.entity.NoticeParm;
import com.da.web.sys_notice.entity.SysNotice;
import com.da.web.sys_notice.mapper.SysNoticeMapper;
import com.da.web.sys_notice.service.SysNoticeService;
import org.springframework.stereotype.Service;

/**
 * @author da
 * @time 2023/12/15 下午 12:34
 */
@Service
public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements SysNoticeService {

    @Override
    public IPage<SysNotice> pageList(NoticeParm parm) {
        IPage<SysNotice> page = new Page<>(parm.getCurrentPage(), parm.getPageSize());
        QueryWrapper<SysNotice> query = new QueryWrapper<>();
        if (StrUtil.isNotEmpty(parm.getNoticeTitle())) {
            query.lambda().like(SysNotice::getNoticeTitle, parm.getNoticeTitle());
        }
        //排序
        query.lambda().orderByDesc(SysNotice::getCreateTime);
        return this.page(page, query);
    }
}
